<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    
    <title>numpy.core.defchararray.array &mdash; NumPy v1.18 Manual</title>
    
    <link rel="stylesheet" type="text/css" href="../../_static/css/spc-bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../../_static/css/spc-extend.css">
    <link rel="stylesheet" href="../../_static/scipy.css" type="text/css" >
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" >
    <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" >
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '1.18.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/language_data.js"></script>
    <script type="text/javascript" src="../../_static/js/copybutton.js"></script>
    <link rel="author" title="About these documents" href="../../about.html" >
    <link rel="index" title="Index" href="../../genindex.html" >
    <link rel="search" title="Search" href="../../search.html" >
    <link rel="top" title="NumPy v1.18 Manual" href="../../index.html" >
    <link rel="up" title="Standard array subclasses" href="../arrays.classes.html" >
    <link rel="next" title="numpy.recarray" href="numpy.recarray.html" >
    <link rel="prev" title="numpy.chararray.zfill" href="numpy.chararray.zfill.html" > 
  </head>
  <body>
<div class="container">
  <div class="top-scipy-org-logo-header" style="background-color: #a2bae8;">
    <a href="../../index.html">
      <img border=0 alt="NumPy" src="../../_static/numpy_logo.png"></a>
    </div>
  </div>
</div>


    <div class="container">
      <div class="main">
        
	<div class="row-fluid">
	  <div class="span12">
	    <div class="spc-navbar">
              
    <ul class="nav nav-pills pull-left">
        <li class="active"><a href="https://numpy.org/">NumPy.org</a></li>
        <li class="active"><a href="https://numpy.org/doc">Docs</a></li>
        
        <li class="active"><a href="../../index.html">NumPy v1.18 Manual</a></li>
        

          <li class="active"><a href="../index.html" >NumPy Reference</a></li>
          <li class="active"><a href="../arrays.html" >Array objects</a></li>
          <li class="active"><a href="../arrays.classes.html" accesskey="U">Standard array subclasses</a></li> 
    </ul>
              
              
    <ul class="nav nav-pills pull-right">
      <li class="active">
        <a href="../../genindex.html" title="General Index"
           accesskey="I">index</a>
      </li>
      <li class="active">
        <a href="numpy.recarray.html" title="numpy.recarray"
           accesskey="N">next</a>
      </li>
      <li class="active">
        <a href="numpy.chararray.zfill.html" title="numpy.chararray.zfill"
           accesskey="P">previous</a>
      </li>
    </ul>
              
	    </div>
	  </div>
	</div>
        

	<div class="row-fluid">
      <div class="spc-rightsidebar span3">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="numpy.chararray.zfill.html"
                        title="previous chapter">numpy.chararray.zfill</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="numpy.recarray.html"
                        title="next chapter">numpy.recarray</a></p>
<div id="searchbox" style="display: none" role="search">
  <h4>Quick search</h4>
    <div>
    <form class="search" action="../../search.html" method="get">
      <input type="text" style="width: inherit;" name="q" />
      <input type="submit" value="search" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
          <div class="span9">
            
        <div class="bodywrapper">
          <div class="body" id="spc-section-body">
            
  <div class="section" id="numpy-core-defchararray-array">
<h1>numpy.core.defchararray.array<a class="headerlink" href="#numpy-core-defchararray-array" title="Permalink to this headline">¶</a></h1>
<dl class="function">
<dt id="numpy.core.defchararray.array">
<code class="sig-prename descclassname">numpy.core.defchararray.</code><code class="sig-name descname">array</code><span class="sig-paren">(</span><em class="sig-param">obj</em>, <em class="sig-param">itemsize=None</em>, <em class="sig-param">copy=True</em>, <em class="sig-param">unicode=None</em>, <em class="sig-param">order=None</em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/numpy/numpy/blob/v1.18.1/numpy/core/defchararray.py#L2618-L2767"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#numpy.core.defchararray.array" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a <code class="xref py py-obj docutils literal notranslate"><span class="pre">chararray</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This class is provided for numarray backward-compatibility.
New code (not concerned with numarray compatibility) should use
arrays of type <code class="xref py py-obj docutils literal notranslate"><span class="pre">string_</span></code> or <code class="xref py py-obj docutils literal notranslate"><span class="pre">unicode_</span></code> and use the free functions
in <code class="xref py py-mod docutils literal notranslate"><span class="pre">numpy.char</span></code> for fast
vectorized string operations instead.</p>
</div>
<p>Versus a regular NumPy array of type <em class="xref py py-obj">str</em> or <em class="xref py py-obj">unicode</em>, this
class adds the following functionality:</p>
<blockquote>
<div><ol class="arabic simple">
<li><p>values automatically have whitespace removed from the end
when indexed</p></li>
<li><p>comparison operators automatically remove whitespace from the
end when comparing values</p></li>
<li><p>vectorized string operations are provided as methods
(e.g. <em class="xref py py-obj">str.endswith</em>) and infix operators (e.g. <code class="docutils literal notranslate"><span class="pre">+,</span> <span class="pre">*,</span> <span class="pre">%</span></code>)</p></li>
</ol>
</div></blockquote>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl>
<dt><strong>obj</strong><span class="classifier">array of str or unicode-like</span></dt><dd></dd>
<dt><strong>itemsize</strong><span class="classifier">int, optional</span></dt><dd><p><em class="xref py py-obj">itemsize</em> is the number of characters per scalar in the
resulting array.  If <em class="xref py py-obj">itemsize</em> is None, and <em class="xref py py-obj">obj</em> is an
object array or a Python list, the <em class="xref py py-obj">itemsize</em> will be
automatically determined.  If <em class="xref py py-obj">itemsize</em> is provided and <em class="xref py py-obj">obj</em>
is of type str or unicode, then the <em class="xref py py-obj">obj</em> string will be
chunked into <em class="xref py py-obj">itemsize</em> pieces.</p>
</dd>
<dt><strong>copy</strong><span class="classifier">bool, optional</span></dt><dd><p>If true (default), then the object is copied.  Otherwise, a copy
will only be made if __array__ returns a copy, if obj is a
nested sequence, or if a copy is needed to satisfy any of the other
requirements (<em class="xref py py-obj">itemsize</em>, unicode, <em class="xref py py-obj">order</em>, etc.).</p>
</dd>
<dt><strong>unicode</strong><span class="classifier">bool, optional</span></dt><dd><p>When true, the resulting <code class="xref py py-obj docutils literal notranslate"><span class="pre">chararray</span></code> can contain Unicode
characters, when false only 8-bit characters.  If unicode is
None and <em class="xref py py-obj">obj</em> is one of the following:</p>
<blockquote>
<div><ul class="simple">
<li><p>a <code class="xref py py-obj docutils literal notranslate"><span class="pre">chararray</span></code>,</p></li>
<li><p>an ndarray of type <em class="xref py py-obj">str</em> or <em class="xref py py-obj">unicode</em></p></li>
<li><p>a Python str or unicode object,</p></li>
</ul>
</div></blockquote>
<p>then the unicode setting of the output array will be
automatically determined.</p>
</dd>
<dt><strong>order</strong><span class="classifier">{‘C’, ‘F’, ‘A’}, optional</span></dt><dd><p>Specify the order of the array.  If order is ‘C’ (default), then the
array will be in C-contiguous order (last-index varies the
fastest).  If order is ‘F’, then the returned array
will be in Fortran-contiguous order (first-index varies the
fastest).  If order is ‘A’, then the returned array may
be in any order (either C-, Fortran-contiguous, or even
discontiguous).</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>

</div>


          </div>
        </div>
          </div>
        </div>
      </div>
    </div>

    <div class="container container-navbar-bottom">
      <div class="spc-navbar">
        
      </div>
    </div>
    <div class="container">
    <div class="footer">
    <div class="row-fluid">
    <ul class="inline pull-left">
      <li>
        &copy; Copyright 2008-2019, The SciPy community.
      </li>
      <li>
      Last updated on Feb 20, 2020.
      </li>
      <li>
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.4.2.
      </li>
    </ul>
    </div>
    </div>
    </div>
  </body>
</html>